package com.qst.controller;

import com.qst.bean.OrderModel;
import com.qst.service.IOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/order")
public class OrderController {

    @Autowired
    IOrderService orderService;

    @GetMapping("/get")
    public String getOrder(){
        return "I am order";
    }

    //创建订单，商品id+用户id
    @GetMapping("/create")
    public OrderModel createOrder(@RequestParam("productId") Long productId,
                                  @RequestParam("userId") Long userId) {
        OrderModel order = orderService.createOrder(productId, userId);
        return order;
    }

}
